#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <string>
#include <iostream>
using namespace std;
class Solution {
public:
    vector<int> to_vector(string version)
    {
        string tmp;
        vector<int> v1;
        bool flag = false;
        for (int i = 0;i < version.size();++i)
        {
            //cerr<<"i="<<i<<endl;
            if ((version[i] != '0' || flag) && version[i] != '.')
            {
                flag = true;
                tmp += version[i];
            }
            else if (version[i] == '.')
            {
                if (tmp.size() == 0)
                {
                    v1.push_back(0);
                }
                else
                {
                    flag = false;
                    //cerr<<tmp<<endl;
                    v1.push_back(stoi(tmp));
                    //cerr<<"!"<<endl;
                    tmp.resize(0);
                }

            }
        }
        //cerr<<tmp<<endl;
        if (tmp.size() != 0)
            v1.push_back(stoi(tmp));
        //cerr<<"!"<<endl;
        return v1;
    }
    int compare(string version1, string version2)
    {
        vector<int> v1 = to_vector(version1);
        vector<int> v2 = to_vector(version2);
        int maxsize = v1.size() > v2.size() ? v1.size() : v2.size();
        v1.resize(maxsize, 0);
        v2.resize(maxsize, 0);
        for (int i = 0;i < maxsize;++i)
        {
            if (v1[i] > v2[i])
            {
                return 1;
            }
            else if (v1[i] < v2[i])
            {
                return -1;
            }
        }
        return 0;
    }
    int compare2(string version1, string version2)
    {
        version1 += '.';
        version2 += '.';
        int i = 0, j = 0;
        while (i < version1.size() || j < version2.size())
        {
            string tmp;
            int flag = false;
            while (i < version1.size() && version1[i] != '.')
            {
                cerr << "i=" << i << endl;
                if (version1[i] != '0' || flag)
                {
                    flag = true;
                    tmp += version1[i];
                }
                ++i;
            }
            cerr << "tmp:" << tmp << endl;
            int a = tmp.size() == 0 ? 0 : stoi(tmp);
            cerr << "a=" << a << endl;
            tmp.resize(0);
            flag = false;
            while (j < version2.size() && version2[j] != '.')
            {
                cerr << "j=" << i << endl;
                if (version2[j] != '0' || flag)
                {
                    flag = true;
                    tmp += version2[j];
                }
                ++j;
            }
            cerr << "tmp:" << tmp << endl;
            int b = tmp.size() == 0 ? 0 : stoi(tmp);
            cerr << "b=" << b << endl;
            if (a > b) return 1;
            if (b > a) return -1;
            ++i;
            ++j;
        }
        return 0;
    }
};